package com.zzjson.io.nio;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.*;
import java.util.Arrays;
import java.util.List;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2020 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.io.nio</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2020年02月25日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
@ToString
@Data
@NoArgsConstructor
public class JavaSerialize extends Test implements Serializable {
	private String name;
	private List<String> cards;
	private Test test;
	private static String full;

	public JavaSerialize(String dd) {
		super(dd);
	}


	public static void main(String[] args) throws IOException, ClassNotFoundException {
		JavaSerialize before = new JavaSerialize();
		JavaSerialize.full = "fuck";
		before.setName("张三");
		before.setCards(Arrays.asList("123X", "223x"));

		// before.setTest(new Test("ds"));

		FileOutputStream fileOutputStream = new FileOutputStream(new File("/Users/zzy/git/learning/learning-io/src/main/java/com/zzjson/io/1.txt"));
		ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
		objectOutputStream.writeObject(before);

		FileInputStream fileInputStream = new FileInputStream(new File("/Users/zzy/git/learning/learning-io/src/main/java/com/zzjson/io/1.txt"));
		ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
		JavaSerialize after = (JavaSerialize) objectInputStream.readObject();

		after.setName("lisi ");
		after.setCards(Arrays.asList("a", "b"));
		System.out.println(before.getCards() == after.getCards());
	}


}
